package com.withoutwords.ui;


import com.samsung.samm.common.SObjectStroke;
import com.samsung.sdraw.AbstractSettingView;
import com.samsung.sdraw.CanvasView;
import com.withoutwords.R;
import com.withoutwords.engine.GameController;

import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;


public class ActorPlayingActivity extends BasePlayinyActivity {

	int selectedWordIndex=0;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.actor_playing);
		initViews();
	}
	@Override
	protected void initViews() {
		// TODO Auto-generated method stub
		super.initViews();
		Button btn = (Button)findViewById(R.id.btnSendActing);
		btn.setOnClickListener(this);
		
		btn = (Button)findViewById(R.id.btnDrawingSettings);
		btn.setOnClickListener(this);
		
		btn = (Button)findViewById(R.id.btnUndo);
		btn.setOnClickListener(this);
		
		/*btn = (Button)findViewById(R.id.btnRedo);
		btn.setOnClickListener(this);*/
		
		btn = (Button)findViewById(R.id.btnErase);
		btn.setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		Button mSettingBtn = (Button)findViewById(R.id.btnDrawingSettings);
		Button mEraseBtn = (Button)findViewById(R.id.btnErase);
		switch(v.getId())
		{
		case R.id.btnSendActing:
		{
			GameController.getInstance().sendActingData(selectedWordIndex, mCanvasView.getData());
			startActivity(new Intent(this,GuesssActivity.class));
			break;
		}
		case R.id.btnDrawingSettings:
		{
			mCanvasView.changeModeTo(CanvasView.PEN_MODE);
			if (mSettingBtn.isSelected())
			{
				if (mSettingView.isShown(AbstractSettingView.PEN_SETTING_VIEW))
				{
					mSettingView.closeView();
				}
				else
				{
					mSettingView.showView(AbstractSettingView.PEN_SETTING_VIEW);
				}
			}
			else
			{
				mSettingBtn.setSelected(true);
				mEraseBtn.setSelected(false);
				if (mSettingView.isShown(AbstractSettingView.ERASER_SETTING_VIEW))
				{
					mSettingView.closeView();
				}
			}
			
			break;
		}
		case R.id.btnUndo:
		{
			mCanvasView.undo();
			//mCanvasView.
			break;
		}
		/*case R.id.btnRedo:
		{
			mCanvasView.redo();
			break;
		}*/
		
		case R.id.btnErase:
		{
			mCanvasView.changeModeTo(CanvasView.ERASER_MODE);
			if (mEraseBtn.isSelected())
			{
				if (mSettingView.isShown(AbstractSettingView.ERASER_SETTING_VIEW))
				{
					mSettingView.closeView();
				}
				else
				{
					mSettingView.showView(AbstractSettingView.ERASER_SETTING_VIEW);
				}
			}
			else
			{
				mEraseBtn.setSelected(true);
				mSettingBtn.setSelected(false);
				if (mSettingView.isShown(AbstractSettingView.PEN_SETTING_VIEW))
				{
					mSettingView.closeView();
				}
			}
		}
		//case text view 
		}
	
		
	}
	@Override
	public void onInitialized() {
		// TODO Auto-generated method stub
	//	mCanvasView.setBGColor(Color.YELLOW);       
		
		//mCanvasView.setca
		
		
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		
	//	mCanvasView.drawSAMMStrokePoint(event.getAction(), 100, 100, 0.6F,SObjectStroke.SAMM_METASTATE_HAND,  event.getDownTime(), event.getEventTime());
		// TODO Auto-generated method stub
		return super.onTouchEvent(event);
	}
	@Override
	public void onWordSelected(int wordIndex) {
		// TODO Auto-generated method stub
		
	}
}
